iconview: Respect the fixed item width when adjusting the wrap width
authorCarlos Garcia Campos <carlosgc@gnome.org>
Sun, 30 Sep 2012 11:09:53 +0000 (13:09 +0200)
committerBenjamin Otte <otte@redhat.com>
Mon, 26 Aug 2013 16:23:55 +0000 (18:23 +0200)
Restore the code the way it was in GTK2.

https://bugzilla.gnome.org/show_bug.cgi?id=680953

gtk/gtkiconview.c

index 070378ab7bda03f439d5c73fee2c521bb3391b7d..20e61750e632c87c6ee709a3c5ab0309203376b5 100644 (file)
@@ -1390,16 +1390,42 @@ adjust_wrap_width (GtkIconView *icon_view)
 {
   if (icon_view->priv->text_cell)
     {
-      gint wrap_width = 50;
+      gint pixbuf_width, wrap_width;
+
+      if (icon_view->priv->items && icon_view->priv->pixbuf_cell)
+        {
+          gtk_cell_renderer_get_preferred_width (icon_view->priv->pixbuf_cell,
+                                                 GTK_WIDGET (icon_view),
+                                                 &pixbuf_width, NULL);
+        }
+      else
+        {
+          pixbuf_width = 0;
+        }
+
+      if (icon_view->priv->item_width >= 0)
+        {
+          if (icon_view->priv->item_orientation == GTK_ORIENTATION_VERTICAL)
+            {
+              wrap_width = icon_view->priv->item_width;
+            }
+          else
+            { 
+              wrap_width = icon_view->priv->item_width - pixbuf_width;
+            }
+
+          wrap_width -= 2 * icon_view->priv->item_padding * 2;
+        }
+      else
+        {
+          wrap_width = MAX (pixbuf_width * 2, 50);
+        }
 
-      /* Here we go with the same old guess, try the icon size and set double
-       * the size of the first icon found in the list, naive but works much
-       * of the time */
       if (icon_view->priv->items && icon_view->priv->pixbuf_cell)
        {
-         gtk_cell_renderer_get_preferred_width (icon_view->priv->pixbuf_cell,
-                                                GTK_WIDGET (icon_view),
-                                                &wrap_width, NULL);
+          /* Here we go with the same old guess, try the icon size and set double
+           * the size of the first icon found in the list, naive but works much
+           * of the time */
          
          wrap_width = MAX (wrap_width * 2, 50);
        }